package com.zy.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.business.domain.TbShift;
import com.zy.business.mapper.ShiftMapper;
import com.zy.business.service.ShiftService;
import com.zy.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description: 班次管理服务层实现
 * @author: whf
 * @create: 2023-02-07 09:15
 **/
@Service
public class ShiftServiceImpl extends ServiceImpl<ShiftMapper, TbShift> implements ShiftService {

    @Autowired
    private ShiftMapper tbShiftMapper;

    /**
     * 查询班次
     *
     * @return 班次
     */
    @Override
    public TbShift selectTbShiftById()
    {
        return tbShiftMapper.selectOne(new QueryWrapper<TbShift>().last("limit 1"));
    }

    /**
     * 新增班次
     *
     * @param tbShift 班次
     * @return 结果
     */
    @Override
    public int insertTbShift(TbShift tbShift)
    {
        tbShift.setCreateTime(DateUtils.getNowDate());
        return tbShiftMapper.insertTbShift(tbShift);
    }

    /**
     * 修改班次
     *
     * @param tbShift 班次
     * @return 结果
     */
    @Override
    public int updateTbShift(TbShift tbShift)
    {
        tbShift.setUpdateTime(DateUtils.getNowDate());
        return tbShiftMapper.updateTbShift(tbShift);
    }
}
